home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / src / mrq_library.lha / lib / examples / c / misterq.c < prev    next >
C/C++ Source or Header  |  1980-09-07  |  3KB  |  134 lines

  1. /************************************************************/
  2. /* example program for mrq.library                          */
  3. /* author: Marcin 'Igor' Wieczorek                          */
  4. /* e-mail: mwieczor@us.edu.pl                               */
  5. /* date: 06.09.2000                                         */
  6. /************************************************************/
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <exec/exec.h>
  10. #include <proto/exec.h>
  11. #include <dos/dos.h>
  12. #include <proto/dos.h>
  13. #include <intuition/intuition.h>
  14.  
  15. #include <libraries/mrq.h>
  16. #include <proto/mrq.h>
  17.  
  18. /************************************************************/
  19. void StartCode(void);
  20. void EndCode(void);
  21.  
  22. /************************************************************/
  23. struct Library *MisterQLibBase;
  24. struct MisterQBase *MisterQBase;
  25. struct MScreen *screen;
  26. struct IntuiMessage *msg;
  27.  
  28. APTR picture = NULL;
  29. APTR palette = NULL;
  30. char *filename = NULL;
  31.  
  32. /************************************************************/
  33. /************************************************************/
  34.  
  35. void main()
  36. {
  37.    int x=0;
  38.    ULONG klasa;
  39.  
  40.    StartCode();
  41.    MRequest("This is MRequest!\nLet's check other functions!",MisterQBase);
  42.  
  43.    if((filename = AslFILERequest("LoadRGB32",MisterQBase)) == 0)
  44.    {
  45.       MRequest("Loading palette failed!\nExiting...",MisterQBase);
  46.       EndCode();
  47.       exit(10);
  48.    }
  49.  
  50.    if( (palette = MLoadFile(filename,MisterQBase,MEMF_ANY)) == 0)
  51.    {
  52.       MRequest("Loading palette failed!\nExiting...",MisterQBase);
  53.       AslFreeFILERequest(filename);
  54.       EndCode();
  55.       exit(10);
  56.    }
  57.  
  58.    AslFreeFILERequest(filename);
  59.  
  60.    MSaveFile("ram:file.rgb32",MisterQBase,palette,3080);
  61.  
  62.    if((filename = AslFILERequest("Chunky (640x480)",MisterQBase)) == 0)
  63.    {
  64.       MRequest("Loading chunky data failed!\nExiting...",MisterQBase);
  65.       EndCode();
  66.       exit(10);
  67.    }
  68.  
  69.    if( (picture = MLoadFile(filename,MisterQBase,MEMF_ANY)) == 0)
  70.    {
  71.       MRequest("Loading chunky data failed!\nExiting...",MisterQBase);
  72.       AslFreeFILERequest(filename);
  73.       EndCode();
  74.       exit(10);
  75.    }
  76.    AslFreeFILERequest(filename);
  77.  
  78.    if( (screen = MOpenScreen(MisterQBase,640,480,0,palette)) == NULL )
  79.    {
  80.       MRequest("Can't open scren!\nExiting...",MisterQBase);
  81.       EndCode();
  82.       exit(10);
  83.    }
  84.  
  85.    C2P(MisterQBase,picture,640,480,0,0);
  86.  
  87.    do
  88.    {
  89.       WaitPort(screen->s_Win_Base->UserPort);
  90.       msg = GetMessage(screen->s_Win_Base->UserPort,MisterQBase);
  91.       klasa = msg->Class;
  92.    } while (klasa != IDCMP_MOUSEBUTTONS);
  93.  
  94.  
  95.    MCloseScreen(MisterQBase,screen);
  96.  
  97.    x = Rnd(500L,MisterQBase);
  98.    printf("Random: %d\n",x);
  99.  
  100.    MRequest("and let's check CopyBytes...\nI'm going to save palette in file RAM:plik.test",MisterQBase);
  101.    CopyBytes(palette,picture,3080);
  102.    MSaveFile("ram:plik.test",MisterQBase,picture,3080);
  103.  
  104.    EndCode();
  105. }
  106.  
  107. /************************************************************/
  108. void StartCode()
  109. {
  110.    MisterQLibBase = OpenLibrary("mrq.library",0);
  111.    MisterQBase = MisterQInit();
  112. }
  113.  
  114. /************************************************************/
  115. void EndCode()
  116. {
  117.    if( palette != NULL)
  118.    {
  119.       MFreeFile(palette,MisterQBase);
  120.       palette = NULL;
  121.    }
  122.  
  123.    if( picture != NULL)
  124.    {
  125.       MFreeFile(picture,MisterQBase);
  126.       picture = NULL;
  127.    }
  128.  
  129.    MisterQCleanUp(MisterQBase);
  130.    CloseLibrary(MisterQLibBase);
  131. }
  132.  
  133. /************************************************************/
  134.